package cn.com.zsw.gblog;

import cn.com.zsw.gblog.config.cache.RedisCache;
import com.thebeastshop.forest.springboot.annotation.ForestScan;

import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;

/**
 * @author: shiwangZhou
 * @description:
 * @date: 2020-06-09 16:55
 */
@SpringBootApplication
@MapperScan({"cn.com.zsw.gblog.admin.mapper", "cn.com.zsw.gblog.modules.*.mapper"})
@EnableScheduling
@ForestScan(basePackages = "cn.com.zsw.gblog.client")
@Slf4j
@ServletComponentScan
public class BlogApplication implements ApplicationRunner {
    @Resource
    RedisCache redisCache;

    public static void main(String[] args) {
        SpringApplication.run(BlogApplication.class, args);
    }

    /**
     * ???????
     *
     * @param args
     */
    @Override
    public void run(ApplicationArguments args) {
        redisCache.setCacheObject("applicationStartTime", System.currentTimeMillis());
    }
    @Bean
    MeterRegistryCustomizer meterRegistryCustomizer(MeterRegistry meterRegistry) {
        return meterRegistry1 -> {
            meterRegistry.config()
                    .commonTags("application", "gblog");
        };
    }
}
